<include file="public@header" />
<link rel="stylesheet" type="text/css" href="__STATIC__/layui/css/layui.css">
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('contract/index')}">合同列表</a></li>
			<li class="active"><a>编辑合同</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20 layui-form" action="{:url('contract/edit')}">
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>客户
				</label>
				<div class="col-md-3 col-sm-6">
					<select class="form-control" name="customer_id" lay-search="">
			          	<option value="">请选择客户</option>
			          	<foreach name="customer_list" item="vo">
			          		<option value="{$vo.id}" <if $vo.id == $row.customer_id>selected</if> >{$vo.name}</option>
			          	</foreach>
			        </select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>负责人
				</label>
				<div class="col-md-3 col-sm-6">
					<select class="form-control" name="charge_id" lay-search="">
			          	<option value="">请选择员工</option>
			          	<foreach name="staff_list" item="vo">
			          		<option value="{$vo.id}" <if $vo.id == $row.charge_id>selected</if> >{$vo.name}</option>
			          	</foreach>
			        </select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>合同编号
				</label>
				<div class="col-md-3 col-sm-10">
					<input type="text" class="form-control" name="contract_no" value="{$row.contract_no}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>合同金额
				</label>
				<div class="col-md-3 col-sm-10">
					<input type="text" class="form-control" name="amount" value="{$row.amount}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>电梯数量
				</label>
				<div class="col-md-3 col-sm-10">
					<input type="text" class="form-control" name="num" value="{$row.num}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>合同签订日期
				</label>
				<div class="col-md-3 col-sm-10">
					<input type="text" class="form-control js-bootstrap-date" name="sign_date" autocomplete="off" value="{$row.sign_date}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>合同执行日期
				</label>
				<div class="col-md-3 col-sm-10">
					<input type="text" class="form-control js-bootstrap-date" name="start_date" autocomplete="off" value="{$row.start_date}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>合同结束日期
				</label>
				<div class="col-md-3 col-sm-10">
					<input type="text" class="form-control js-bootstrap-date" name="end_date" autocomplete="off" value="{$row.end_date}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">
					<span class="form-required">*</span>合同附件
				</label>
				<div class="col-md-3 col-sm-10">
					<ul id="files" class="pic-list list-unstyled form-inline">
						<notempty name="row.files">
                            <foreach name="row.files" item="vo">
                                <li id="saved-file{$key}">
                                    <input id="file-{$key}" type="hidden" name="file_urls[]"
                                           value="{$vo.url}">
                                    <input class="form-control" id="file-{$key}-name" type="text"
                                           name="file_names[]"
                                           value="{$vo.name}" style="width: 200px;" title="图片名称">
                                    <a id="file-{$key}-preview" href="{$vo.download_url}" target="_blank">下载</a>
                                    <a href="javascript:uploadOne('文件上传','#file-{$key}','file');">替换</a>
                                    <a href="javascript:(function(){$('#saved-file{$key}').remove();})();">移除</a>
                                </li>
                            </foreach>
                        </notempty>
                    </ul>
                    <br>
                    <a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl','file');"
                       class="btn btn-sm btn-default">选择文件</a>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$row.id}">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script src="__STATIC__/layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['form'], function(){
			var form = layui.form;
		});
	</script>
	<script type="text/html" id="files-item-tpl">
    <li id="saved-file{id}">
        <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
        <input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
               style="width: 200px;" title="文件名称">
        <a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
        <a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
        <a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
    </li>
</script>
</body>
</html>